<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>设备列表</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/common.css"/>
		<style>
			.time-ul li{
				padding: 1rem .5rem;
			}
		</style>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">设备列表</h1>
		</header>
		<div class="mui-content">
	    	<ul class="time-ul">
			    <li data-type =''>
            		<a>所有设备</a>
			    </li>
			</ul>
		</div>
		<script src="../js/mui.min.js"></script>
		<script>
			mui.init({
				swipeBack:true //启用右滑关闭功能
			});
			
			var buildingList = JSON.parse(localStorage.getItem('inAndOut_buildingList'));
			var newBuildingList = unique(buildingList);
			mui.each(newBuildingList, function(key,item) { 
				document.getElementsByClassName('time-ul')[0].insertAdjacentHTML('beforeEnd','<li data-type = "'+ item +'"><a>'+ item +'</a></li>'); 
			});
			
			mui(".time-ul").on('tap','li',function(){
				var deviceType = this.getAttribute('data-type');
				localStorage.setItem("inAndOut_deviceType",deviceType);
				mui.back();
			})
			
			//去掉重复项
			function unique(arr) {
			    var result = [], hash = {};
			    for (var i = 0, elem; (elem = arr[i]) != null; i++) {
			        if (!hash[elem]) {
			            result.push(elem);
			            hash[elem] = true;
			        }
			    }
			    return result;
			}
				
		</script>
	</body>

</html>